/**
 * Created by Neville Kadwa.
 */

package org.shiftone.cdep.store;

import java.io.PrintStream;
import java.io.PrintWriter;

import org.apache.log4j.Logger;

public class StoreException extends Exception
{

    public static final Logger LOG = Logger.getLogger(StoreException.class);

    private Throwable rootCause = null;

    public StoreException(String message)
    {
        super(message);
    }

    public StoreException(String message, Throwable rootCause)
    {

        super(message);

        this.rootCause = rootCause;
    }

    public void printStackTrace()
    {
        printStackTrace(System.out);
    }

    public void printStackTrace(PrintStream printStream)
    {

        PrintWriter printWriter = null;

        printWriter = new PrintWriter(printStream);

        printStackTrace(printWriter);
        printWriter.flush();
        printWriter.close();
    }

    public void printStackTrace(PrintWriter printWriter)
    {

        super.printStackTrace(printWriter);

        if (rootCause != null)
        {
            printWriter.println("root cause is:");
            rootCause.printStackTrace(printWriter);
        }
    }

}

/* EOF */
